<template>
	<view class="wrapper">
		<view class="earnings-wrapper">
			<view class="earnings">
				<view>
					<view class="earnings-title">下级欠款(元)</view>
					<view class="earnings-amount">{{amount}}</view>
				</view>
			</view>
			<view class="earnings-detail" @click="navTo({walletType:1})">查看明细</view>
		</view>
	</view>
</template>

<script>
	import {
		income
	} from "_a/earnings/index";
	export default {
		data() {
			return {
				amount: 0,
			};
		},
		computed: {
			account() {},
		},
		// 下拉刷新
		async onPullDownRefresh() {
			this.$store.dispatch("getUserDetail").then((res) => {
				uni.stopPullDownRefresh();
				this.getData();
				this.$tip.toast("刷新成功!", "success", 500);
			});
		},
		onShow() {
			this.getData();
		},
		methods: {
			// async initData() {
			// 	await this.getData();
			// },
			getData() {
				this.$store.dispatch("getUserDetail").then((res) => {
					this.list = res.wallet;
					// this.list = this.$store.getters.userInfo.wallet;
					this.num = this.list.reduce((total, item) => {
						return (total +=
							item.usableAmount - item.transitAmount - item.freezeAmount);
					}, 0);
					this.info = res.info;
					this.agentPermission.allowWithdraw = res?.agentPermission?.allowWithdraw;
					this.$forceUpdate()
				});
			},
			navTo(item) {
				this.$nav.push({
					path: "/pages/earnings/earningsDetails",
					query: {
						type: item.walletType
					},
				});
			},
			earningsWithdrawalHandle(item) {
				const routeName = `/pages/earnings/earningsWithdrawal?type=${item.walletType}`;
				this.$nav.push({
					path: routeName,
				});
			},
			// 提现记录
			withdrawalInfoHandel() {
				this.$nav.push({
					path: "/pages/earnings/withdrawalList",
				});
			},
			handleCapital(item) {
				this.$nav.push({
					path: "/pages/earnings/capitalPool",
				});
			}

		},
	};
</script>

<style lang="scss" scoped>
	.wrapper{
		padding: 0px $uni-spacing-row-lg;
		.earnings-wrapper{
			margin-top: $uni-spacing-col-lg;
			border-radius: $uni-border-radius-xl;
			padding: $uni-spacing-row-lg 0;
			overflow: hidden;
			background:url('../../common/images/earnings/earnings-bg.png') no-repeat;
			background-size: 100% 100%;
			display: flex;
			justify-content: space-between;
			align-items: center;
			view{
				color: #fff;	
			}
			.earnings-title{
				padding-left: $uni-spacing-row-lg;
			}
			.earnings-amount{
				font-size: $uni-font-size-xl;
				font-weight: bold;
				margin-top: $uni-spacing-col-lg;
				padding-left: $uni-spacing-row-lg;
			}
			.earnings-detail{
				background: rgba(255, 255, 255, 0.4);
				border-bottom-left-radius:15px;
				border-top-left-radius:15px;
				padding: $uni-spacing-col-sm $uni-spacing-row-base;
				font-size: $uni-font-size-sm;
			}
		}
		
	}
</style>>